import 'package:eye_flutter_app/provider/test.dart';
import 'package:eye_flutter_app/utils/storage.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'DataTable/node1_base.dart';
import 'DataTable/node2_operation.dart';
import 'Table/node1_base.dart';

class TablePage extends StatefulWidget {
  TablePage({Key? key}) : super(key: key);

  @override
  State<TablePage> createState() => _TablePageState();
}

class _TablePageState extends State<TablePage> {
  int? counter = 0;

  _getData() async {
    int? counter1 = await Storage.getInt('counter');
    setState(() {
      print('执行了');
      counter = counter1;
      print(counter);
    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _getData();
  }

  @override
  Widget build(BuildContext context) {
    var testProvider = Provider.of<TestProvider>(context);
    return Scaffold(
      appBar: AppBar(
        title: Text('表格'),
      ),
      body: ListView(
        children: [
          Text('provider管理的count值：${testProvider.count}'),
          Text(counter.toString()),
          ElevatedButton(
              onPressed: () async {
                Storage.setInt('counter', 30);
              },
              child: Text('更新缓存数据')),
          Padding(
            padding: EdgeInsets.all(10),
            child: Center(
              child: Text('Table'),
            ),
          ),
          CustomTable(),
          Padding(
            padding: EdgeInsets.all(10),
            child: Center(
              child: Text('DataTable'),
            ),
          ),
          CustomDataTable(),
          Padding(
            padding: EdgeInsets.all(10),
            child: Center(
              child: Text('SortDataTable'),
            ),
          ),
          SortDataTable(),
        ],
      ),
    );
    ;
  }
}
